var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function o() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((o.prototype = i.prototype), new o()));
      };
    })(),
  CommonUIDialog = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.selArr = []),
        (t.tmpSelArr = []),
        WebSocketService.addListener({
          caller: t,
          code: 5317,
          method: t.onLoadListData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 5313,
          method: t.onLoadCommonResultData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 5314,
          method: t.onLoadCommonResultData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 5319,
          method: t.onLoadWuPinLiHeData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 5320,
          method: t.onLoadWuPinResultData,
        }),
        (t.list_role_sale.vScrollBarSkin = ""),
        (t.list_role_sale.selectEnable = !0),
        t.list_role_sale.on(Laya.Event.CLICK, t, t.onDidListRoleSaleClick),
        (t.list_wupin_lihe.vScrollBarSkin = ""),
        (t.list_wupin_lihe.selectEnable = !0),
        t.list_wupin_lihe.on(Laya.Event.CLICK, t, t.onSelectWuPinItemAction),
        (t.list_wupin_lihe.renderHandler = new Handler(
          t,
          t.onUpdateRendeHandler
        )),
        t.label_item_close1.on(Laya.Event.CLICK, t, t.onDidItemCancle),
        t.label_item_close2.on(Laya.Event.CLICK, t, t.onDidItemCancle),
        t.label_item_close3.on(Laya.Event.CLICK, t, t.onDidItemCancle),
        t.btn_sure_item.on(Laya.Event.CLICK, t, t.onSureItemClick),
        t.input_com_name1.on(Laya.Event.BLUR, t, t.onInputChange),
        t.input_com_name1.on(Laya.Event.FOCUS, t, t.onInputChange),
        t.input_com_name2.on(Laya.Event.BLUR, t, t.onInputChange),
        t.input_com_name2.on(Laya.Event.FOCUS, t, t.onInputChange),
        t.input_com_name3.on(Laya.Event.BLUR, t, t.onInputChange),
        t.input_com_name3.on(Laya.Event.FOCUS, t, t.onInputChange),
        t.btn_cancle_role_sale.on(Laya.Event.CLICK, t, t.onDidCancleRoleClick),
        t
      );
    }
    return (
      __extends(t, e),
      (t.prototype.onInputChange = function () {
        console.log("123123"), this.getTextInputData();
      }),
      (t.showCommonUIDialog = function (e, i, o, n) {
        return (
          null == this.uiDialog &&
            ((this.uiDialog = new t()), (this.uiDialog.zOrder = 1e3)),
          (this.uiDialog.itemObj = e),
          this.uiDialog.popup(!0),
          this.uiDialog.initViews(i),
          o &&
            n &&
            ((this.uiDialog.caller = o), (this.uiDialog.callMethod = n)),
          this.uiDialog
        );
      }),
      (t.prototype.initViews = function (e) {
        "accountRole" == e
          ? (this.accountRoleChange(),
            (this.panel_role_sale.visible = !0),
            (this.panel_wupin_lihe.visible = !1),
            (this.btn_sure_item.label = "取消"))
          : "lihe" == e &&
            ((this.label_item_title.text = this.itemObj.name
              ? this.itemObj.name
              : "礼盒"),
            (this.panel_role_sale.visible = !1),
            (this.panel_wupin_lihe.visible = !0),
            (this.btn_sure_item.label = "购买"),
            WebSocketService.send({ c: 5319, d: { roleId: Global.roleId } }));
      }),
      (t.prototype.accountRoleChange = function () {
        var e = Global.roleId;
        e || (e = this.itemObj.id),
          WebSocketService.send({ c: 5317, d: { tradeRoleId: e } });
      }),
      (t.prototype.onLoadListData = function (e) {
        if (0 == e.code) {
          var t;
          e.data && (t = e.data);
          for (var i, o = [], n = t, a = 0; a < n.length; a++)
            (i = {
              item_sale_name: { text: n[a].purposeRoleName },
              purposeUserId: n[a].purposeUserId,
              purposeRoleId: n[a].purposeRoleId,
              purposePhone: n[a].purposePhone,
              purposeRoleName: n[a].purposeRoleName,
            }),
              o.push(i);
          this.list_role_sale.array = o;
        } else ToastView.toastView(e.msg);
      }),
      (t.prototype.onDidListRoleSaleClick = function (e) {
        if ("" != e.target.name) {
          this.selItem = void 0;
          var t = this.list_role_sale.selectedItem;
          this.selItem = t;
          var i = this.selItem.purposePhone.substring(
            this.selItem.length - 4,
            this.selItem.length
          );
          NormalNewDialog.showNewNormalTwoItemDialog(
            "提示",
            "您确定要和\n\n手机尾号：" +
              i +
              "\n角色名：" +
              this.selItem.purposeRoleName +
              "\n\n进行交易吗?\n确定后您将失去该角色并将转移到该名用户下。",
            this,
            this.onSureSaleCallBack,
            !0
          );
        }
      }),
      (t.prototype.onSureSaleCallBack = function () {
        var e = Global.roleId;
        e || (e = this.itemObj.id);
        var t = this.selItem.purposePhone.replace(
          this.selItem.purposePhone.substring(3, 7),
          "****"
        );
        WebSocketService.send({
          c: 5313,
          d: { roleId: e, phone: t, purposeUserId: this.selItem.purposeUserId },
        });
      }),
      (t.prototype.onLoadCommonResultData = function (e) {
        5313 == e.act_id
          ? 0 == e.code &&
            (this.close(),
            ToastView.toastView(e.msg),
            this.caller && this.callMethod.call(this.caller, "成功"),
            WebSocketService.send({ c: 3, d: null }))
          : 5314 == e.act_id && this.close();
      }),
      (t.prototype.onDidCancleRoleClick = function () {
        var e = Global.roleId;
        e || (e = this.itemObj.id),
          WebSocketService.send({ c: 5314, d: { roleId: e, type: 2 } });
      }),
      (t.prototype.onLoadWuPinLiHeData = function (e) {
        if (0 == e.code) {
          var t;
          e.data && (t = e.data);
          for (var i, o = [], n = t, a = 0; a < n.length; a++)
            (i = {
              item_wupin_item: {
                text: a + 1 + ". " + n[a].name + "(" + n[a].price + " 金币)",
              },
              item_wupin_item_desc: { text: n[a].descr },
              name: n[a].name,
              price: n[a].price,
              id: n[a].id,
              descr: n[a].descr,
            }),
              o.push(i);
          this.list_wupin_lihe.array = o;
        } else ToastView.toastView(e.msg);
      }),
      (t.prototype.onUpdateRendeHandler = function (e, t) {}),
      (t.prototype.onSelectWuPinItemAction = function (e) {
        if ("" != e.target.name) {
          var t = this.list_wupin_lihe.selectedItem;
          if (this.selArr.length < 3) {
            for (var i = !1, o = 0; o < this.selArr.length; o++) {
              e = this.selArr[o];
              if (t.id == e.id) {
                i = !0;
                break;
              }
            }
            i || this.selArr.push(t);
          }
          this.updateSelectWuPinLiHeListData();
        }
      }),
      (t.prototype.updateSelectWuPinLiHeListData = function () {
        this.tmpSelArr = [];
        for (var e = 0; e < this.selArr.length; e++) {
          var t = this.selArr[e];
          0 == e
            ? (this.label_item_name1.text = t.name + "\n" + t.price)
            : 1 == e
            ? (this.label_item_name2.text = t.name + "\n" + t.price)
            : 2 == e && (this.label_item_name3.text = t.name + "\n" + t.price);
        }
      }),
      (t.prototype.onDidItemCancle = function (e) {
        this.getTextInputData(),
          "" != e.target.name &&
            ("close1" == e.target.name
              ? this.selArr.splice(0, 1)
              : "close2" == e.target.name
              ? this.selArr.splice(1, 1)
              : "close3" == e.target.name && this.selArr.splice(2, 1),
            console.log(this.selArr),
            this.initWuPinItemData(),
            this.updateSelectWuPinLiHeListData());
      }),
      (t.prototype.initWuPinItemData = function () {
        (this.label_item_name1.text = ""),
          (this.input_com_name1.text = "0"),
          (this.label_item_name2.text = ""),
          (this.input_com_name2.text = "0"),
          (this.label_item_name3.text = ""),
          (this.input_com_name3.text = "0");
        for (var e = 0; e < this.selArr.length; e++) {
          var t = this.selArr[e];
          0 == e
            ? (this.input_com_name1.text = t.num ? t.num : "0")
            : 1 == e
            ? (this.input_com_name2.text = t.num ? t.num : "0")
            : 2 == e && (this.input_com_name3.text = t.num ? t.num : "0");
        }
      }),
      (t.prototype.getTextInputData = function () {
        for (var e = 0; e < this.selArr.length; e++) {
          this.selArr[e];
          0 == e
            ? (this.selArr[e].num = this.input_com_name1.text)
            : 1 == e
            ? (this.selArr[e].num = this.input_com_name2.text)
            : 2 == e && (this.selArr[e].num = this.input_com_name3.text);
        }
      }),
      (t.prototype.onSureItemClick = function () {
        if (this.selArr.length < 3)
          ToastView.toastView("必须选三种不同的道具且购买数量的和为20");
        else {
          for (var e, t, i, o, n, a = 0, l = 0; l < this.selArr.length; l++) {
            var s = this.selArr[l];
            0 == l
              ? ((e = s.id), (t = s.num))
              : 1 == l
              ? ((i = s.id), (o = s.num))
              : 2 == l && ((n = s.id), (a = s.num));
          }
          void 0 != t && void 0 != o && void 0 != a
            ? t + o + a < 20 || t <= 0 || o <= 0 || a <= 0
              ? ToastView.toastView("必须选三种不同的道具且购买数量的和为20")
              : WebSocketService.send({
                  c: 5320,
                  d: {
                    roleId: Global.roleId,
                    chooseGid1: e,
                    chooseNum1: t,
                    chooseGid2: i,
                    chooseNum2: o,
                    chooseGid3: n,
                    chooseNum3: a,
                  },
                })
            : ToastView.toastView("必须选三种不同的道具且购买数量的和为20");
        }
      }),
      (t.prototype.onLoadWuPinResultData = function (e) {
        ToastView.toastView(e.msg);
      }),
      t
    );
  })(ui.dialog.CommonUIDialogUI);
